home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / VGAKIT50.ARJ / SVGAMODE.ASM < prev    next >
Assembly Source File  |  1992-06-25  |  3KB  |  209 lines

  1.  
  2.     include model.h
  3.     include    vesa.h
  4.  
  5. ;
  6. ;    VGAKIT Version 5.0
  7. ;
  8. ;    Copyright 1988,89,90,91,92 John Bridges
  9. ;    Free for use in commercial, shareware or freeware applications
  10. ;
  11. ;    SVGAMODE.ASM
  12. ;
  13. ;
  14. .data
  15.     extrn    cirrus:byte,everex:byte,paradise:byte,tseng:byte,trident:byte
  16.     extrn    t8900:byte,ativga:byte,aheada:byte,aheadb:byte
  17.     extrn    oaktech:byte,video7:byte,chipstech:byte,tseng4:byte,genoa:byte
  18.     extrn    ncr:byte,compaq:byte,acumos:byte,vesa:byte
  19.  
  20.     extrn    curbk:word,bksize:word
  21.  
  22.     public    maxx,maxy,scanline,ourseg
  23.  
  24. maxx    dw    ?        ;scanline of screen in pixels
  25. maxy    dw    ?        ;height of screen in pixels
  26. scanline dw    ?        ;actual width screen in bytes
  27. ourseg    dw    ?        ;segment of screen buffer
  28.  
  29.  
  30.     public    adrtbl
  31.  
  32. adrtbl    dd    1024 dup (?)    ;offset and bank for each scanline
  33.  
  34. .code
  35.  
  36.     public    svgamode
  37.     public    txtmode
  38.     public    setmany
  39.  
  40. svgamode proc            ;Set 640x480x256 on most SVGA cards
  41.     mov    [ourseg],0a000h
  42.     mov    ax,640
  43.     mov    [maxx],ax        ;default width to 640 for now
  44.     mov    [scanline],ax
  45.  
  46.     cmp    [vesa],0
  47.     jz    novs
  48.     mov    bx,101h
  49.     call    vesaset
  50.     jmp    godo2
  51. novs:    cmp    [compaq],0
  52.     jz    nocp
  53.     mov    [scanline],1024
  54.     mov    ax,2eh
  55.     jmp    godo
  56. nocp:    cmp    [genoa],0
  57.     jz    nogn
  58.     mov    ax,5ch
  59.     jmp    godo
  60. nogn:    cmp    [ncr],0
  61.     jz    noncr
  62.     mov    ax,5fh
  63.     jmp    godo
  64. noncr:    cmp    [oaktech],0
  65.     jz    noak
  66.     mov    ax,53h
  67.     jmp    short godo
  68. noak:    cmp    [aheada],0
  69.     jnz    @f
  70.     cmp    [aheadb],0
  71.     jz    noab
  72. @@:    mov    ax,61h
  73.     jmp    short godo
  74. noab:    cmp    [everex],0
  75.     jz    noev
  76.     mov    ax,70h
  77.     mov    bl,30h
  78.     jmp    short godo
  79. noev:    cmp    [ativga],0
  80.     jz    noati
  81.     mov    ax,62h
  82.     jmp    short godo
  83. noati:    cmp    [trident],0
  84.     jz    notr
  85.     mov    ax,5dh
  86.     jmp    short godo
  87. notr:    cmp    [video7],0
  88.     jz    nov7
  89.     mov    ax,6f05h
  90.     mov    bl,67h
  91.     jmp    short godo
  92. nov7:    cmp    [chipstech],0
  93.     jz    noct
  94.     mov    ax,79h
  95.     jmp    short godo
  96. noct:    cmp    [acumos],0
  97.     jnz    dopd
  98.     cmp    [paradise],0
  99.     jz    nopd
  100. dopd:    mov    ax,5fh
  101.     jmp    short godo
  102. nopd:    cmp    [tseng],0
  103.     jz    nots
  104.     mov    ax,2eh
  105. godo:    int    10h
  106.  
  107. godo2:    mov    [curbk],-1
  108.     mov    ax,40h
  109.     mov    es,ax
  110.     mov    al,es:[84h]        ;get height of screen
  111.     inc    al
  112.     mul    byte ptr es:[85h]
  113.     mov    [maxy],ax
  114.     call    mkadrtbl
  115. nots:    ret
  116. svgamode endp
  117.  
  118. vesaset    proc    near uses di
  119.     local    modebuf[256]:byte
  120.  
  121.     push    bx
  122.     mov    ax,4f02h        ; set the VESA videomode
  123.     int    10h
  124.     pop    cx
  125.     mov    ax,ss
  126.     mov    es,ax
  127.     lea    di,modebuf[0]        ; get the mode information
  128.     mov    ax,4f01h
  129.     int    10h
  130.     mov    ax,modebuf.vesamode.WinSize
  131.     mov    [bksize],ax        ; bank size from vesamode structure
  132.     mov    ax,modebuf.vesamode.BytesPerLine
  133.     mov    [scanline],ax        ; scan line byte width from vesamode
  134.     ret
  135. vesaset    endp
  136.  
  137. txtmode    proc
  138.     mov    ax,3
  139.     int    10h
  140.     ret
  141. txtmode    endp
  142.  
  143. setmany proc    palbuf:ptr byte,begcol:word,numcol:word
  144. if @Datasize
  145.     les    dx,[palbuf]
  146. else
  147.     mov    ax,ds
  148.     mov    es,ax
  149.     mov    dx,[palbuf]
  150. endif
  151.     mov    bx,[begcol]
  152.     mov    cx,[numcol]
  153.     mov    ax,1012h
  154.     int    10h
  155.     ret
  156. setmany endp
  157.  
  158. mkadrtbl proc    uses di si
  159.     mov    di,offset adrtbl
  160.     mov    ax,ds
  161.     mov    es,ax
  162.     mov    bx,[maxy]
  163.  
  164.     mov    ax,[bksize]
  165.     cmp    ax,64
  166.     jz    nobnk
  167.     mov    cl,10
  168.     shl    ax,cl
  169.     dec    ax
  170.     mov    si,ax
  171.     mov    cl,10
  172.     mov    ax,[bksize]
  173. shlp:    inc    cl
  174.     shr    ax,1
  175.     jnz    shlp
  176.     xor    ax,ax
  177.     xor    dx,dx
  178. lp:    push    ax
  179.     shr    ax,cl
  180.     add    dx,ax
  181.     pop    ax
  182.     and    ax,si
  183.     stosw
  184.     xchg    ax,dx
  185.     stosw
  186.     xchg    ax,dx
  187.     add    ax,[scanline]
  188.     dec    bx
  189.     jnz    lp
  190.     ret
  191.  
  192. nobnk:    xor    ax,ax
  193.     xor    dx,dx
  194.     mov    si,[scanline]
  195.     mov    cx,bx
  196. nlp:    stosw
  197.     xchg    ax,dx
  198.     stosw
  199.     xchg    ax,dx
  200.     add    ax,si
  201.     adc    dx,0
  202.     loop    nlp
  203.     ret
  204.  
  205. mkadrtbl endp
  206.  
  207.     end
  208.  
  209.